In [9]:
import pandas as pd
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
import plotly as py
import plotly.figure_factory as ff
In [17]:
df = pd.read_csv(r"C:\Users\Tatan\UKBankCust.csv",encoding='latin1')

table = ff.create_table(df)
py.iplot(table, filename='jupyter-table1')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-db83d6718580> in <module>
      2 
      3 table = ff.create_table(df)
----> 4 py.iplot(table, filename='jupyter-table1')

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\_plotly_utils\importers.py in __getattr__(import_name)
     37             return getattr(class_module, class_name)
     38 
---> 39         raise AttributeError(
     40             "module {__name__!r} has no attribute {name!r}".format(
     41                 name=import_name, __name__=parent_name

AttributeError: module 'plotly' has no attribute 'iplot'
In [1]:
import seaborn as sns
sns.set()
In [4]:
import pandas as pd
UKBankCust = pd.read_csv(r"C:\Users\Tatan\UKBankCust.csv",encoding='latin1')
UKBankCust.describe()
Out[4]:
Customer ID Age Balance
count 4.014000e+03 4014.000000 4014.000000
mean 1.696831e+08 38.611111 39766.448274
std 8.865374e+07 9.819121 29859.489192
min 1.000000e+08 15.000000 11.520000
25% 1.000020e+08 31.000000 16115.367500
50% 1.000038e+08 37.000000 33567.330000
75% 2.000031e+08 45.000000 57533.930000
max 4.000038e+08 64.000000 183467.700000
In [5]:
UKBankCust.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4014 entries, 0 to 4013
Data columns (total 7 columns):
 #   Column              Non-Null Count  Dtype  
---  ------              --------------  -----  
 0   Customer ID         4014 non-null   int64  
 1   Name                4014 non-null   object 
 2   Gender              4014 non-null   object 
 3   Age                 4014 non-null   int64  
 4   Region              4014 non-null   object 
 5   Job Classification  4014 non-null   object 
 6   Balance             4014 non-null   float64
dtypes: float64(1), int64(2), object(4)
memory usage: 219.6+ KB
In [6]:
sns.scatterplot(x='Age',y='Balance',data=UKBankCust)
Out[6]:
<AxesSubplot:xlabel='Age', ylabel='Balance'>
In [11]:
# adding some additional parameters
sns.scatterplot(x='Age',y='Gender',hue='Job Classification', data=UKBankCust)
Out[11]:
<AxesSubplot:xlabel='Age', ylabel='Gender'>
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\anaconda3\envs\UKBANKCUS1\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
    339                 pass
    340             else:
--> 341                 return printer(obj)
    342             # Finally look for special method names
    343             method = get_real_method(obj, self.print_method)

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig)
    246 
    247     if 'png' in formats:
--> 248         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    249     if 'retina' in formats or 'png2x' in formats:
    250         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
    130         FigureCanvasBase(fig)
    131 
--> 132     fig.canvas.print_figure(bytes_io, **kw)
    133     data = bytes_io.getvalue()
    134     if fmt == 'svg':

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2191                            else suppress())
   2192                     with ctx:
-> 2193                         self.figure.draw(renderer)
   2194 
   2195                     bbox_inches = self.figure.get_tightbbox(

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
   1861 
   1862             self.patch.draw(renderer)
-> 1863             mimage._draw_list_compositing_images(
   1864                 renderer, self, artists, self.suppressComposite)
   1865 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
   2746             renderer.stop_rasterizing()
   2747 
-> 2748         mimage._draw_list_compositing_images(renderer, self, artists)
   2749 
   2750         renderer.close_group('axes')

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
    929     def draw(self, renderer):
    930         self.set_sizes(self._sizes, self.figure.dpi)
--> 931         Collection.draw(self, renderer)
    932 
    933 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
    383             else:
    384                 combined_transform = transform
--> 385             extents = paths[0].get_extents(combined_transform)
    386             if (extents.width < self.figure.bbox.width
    387                     and extents.height < self.figure.bbox.height):

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\path.py in get_extents(self, transform, **kwargs)
    601                 xys.append(curve([0, *dzeros, 1]))
    602             xys = np.concatenate(xys)
--> 603         return Bbox([xys.min(axis=0), xys.max(axis=0)])
    604 
    605     def intersects_path(self, other, filled=True):

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\numpy\core\_methods.py in _amin(a, axis, out, keepdims, initial, where)
     41 def _amin(a, axis=None, out=None, keepdims=False,
     42           initial=_NoValue, where=True):
---> 43     return umr_minimum(a, axis, None, out, keepdims, initial, where)
     44 
     45 def _sum(a, axis=None, dtype=None, out=None, keepdims=False,

ValueError: zero-size array to reduction operation minimum which has no identity
<Figure size 432x288 with 1 Axes>
In [24]:
Age_vs_Balance = sns.relplot(x="Age", y="Balance", kind="line",sort=False, data=UKBankCust)
In [15]:
sns.relplot(x='Age',y='Balance',hue='Region',size='Age',col='Gender',data=UKBankCust)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-15-c145ecf50f1e> in <module>
----> 1 sns.relplot(x='Age',y='Balance',hue='Region',size='Age',col='Gender',data=UKBankCust)

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\seaborn\relational.py in relplot(x, y, hue, size, style, data, row, col, col_wrap, row_order, col_order, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, dashes, style_order, legend, kind, height, aspect, facet_kws, **kwargs)
   1701         p.add_legend_data(g.axes.flat[0])
   1702         if p.legend_data:
-> 1703             g.add_legend(legend_data=p.legend_data,
   1704                          label_order=p.legend_order)
   1705 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\seaborn\axisgrid.py in add_legend(self, legend_data, title, label_order, **kwargs)
    105             # Draw the plot to set the bounding boxes correctly
    106             if hasattr(self.fig.canvas, "get_renderer"):
--> 107                 self.fig.draw(self.fig.canvas.get_renderer())
    108 
    109             # Calculate and set the new width of the figure so the legend fits

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
   1861 
   1862             self.patch.draw(renderer)
-> 1863             mimage._draw_list_compositing_images(
   1864                 renderer, self, artists, self.suppressComposite)
   1865 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
   2746             renderer.stop_rasterizing()
   2747 
-> 2748         mimage._draw_list_compositing_images(renderer, self, artists)
   2749 
   2750         renderer.close_group('axes')

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
    929     def draw(self, renderer):
    930         self.set_sizes(self._sizes, self.figure.dpi)
--> 931         Collection.draw(self, renderer)
    932 
    933 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
    383             else:
    384                 combined_transform = transform
--> 385             extents = paths[0].get_extents(combined_transform)
    386             if (extents.width < self.figure.bbox.width
    387                     and extents.height < self.figure.bbox.height):

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\path.py in get_extents(self, transform, **kwargs)
    601                 xys.append(curve([0, *dzeros, 1]))
    602             xys = np.concatenate(xys)
--> 603         return Bbox([xys.min(axis=0), xys.max(axis=0)])
    604 
    605     def intersects_path(self, other, filled=True):

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\numpy\core\_methods.py in _amin(a, axis, out, keepdims, initial, where)
     41 def _amin(a, axis=None, out=None, keepdims=False,
     42           initial=_NoValue, where=True):
---> 43     return umr_minimum(a, axis, None, out, keepdims, initial, where)
     44 
     45 def _sum(a, axis=None, dtype=None, out=None, keepdims=False,

ValueError: zero-size array to reduction operation minimum which has no identity
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\anaconda3\envs\UKBANKCUS1\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
    339                 pass
    340             else:
--> 341                 return printer(obj)
    342             # Finally look for special method names
    343             method = get_real_method(obj, self.print_method)

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig)
    246 
    247     if 'png' in formats:
--> 248         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    249     if 'retina' in formats or 'png2x' in formats:
    250         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
    130         FigureCanvasBase(fig)
    131 
--> 132     fig.canvas.print_figure(bytes_io, **kw)
    133     data = bytes_io.getvalue()
    134     if fmt == 'svg':

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2191                            else suppress())
   2192                     with ctx:
-> 2193                         self.figure.draw(renderer)
   2194 
   2195                     bbox_inches = self.figure.get_tightbbox(

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
   1861 
   1862             self.patch.draw(renderer)
-> 1863             mimage._draw_list_compositing_images(
   1864                 renderer, self, artists, self.suppressComposite)
   1865 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
   2746             renderer.stop_rasterizing()
   2747 
-> 2748         mimage._draw_list_compositing_images(renderer, self, artists)
   2749 
   2750         renderer.close_group('axes')

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
    929     def draw(self, renderer):
    930         self.set_sizes(self._sizes, self.figure.dpi)
--> 931         Collection.draw(self, renderer)
    932 
    933 

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\collections.py in draw(self, renderer)
    383             else:
    384                 combined_transform = transform
--> 385             extents = paths[0].get_extents(combined_transform)
    386             if (extents.width < self.figure.bbox.width
    387                     and extents.height < self.figure.bbox.height):

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\matplotlib\path.py in get_extents(self, transform, **kwargs)
    601                 xys.append(curve([0, *dzeros, 1]))
    602             xys = np.concatenate(xys)
--> 603         return Bbox([xys.min(axis=0), xys.max(axis=0)])
    604 
    605     def intersects_path(self, other, filled=True):

~\anaconda3\envs\UKBANKCUS1\lib\site-packages\numpy\core\_methods.py in _amin(a, axis, out, keepdims, initial, where)
     41 def _amin(a, axis=None, out=None, keepdims=False,
     42           initial=_NoValue, where=True):
---> 43     return umr_minimum(a, axis, None, out, keepdims, initial, where)
     44 
     45 def _sum(a, axis=None, dtype=None, out=None, keepdims=False,

ValueError: zero-size array to reduction operation minimum which has no identity
<Figure size 720x360 with 2 Axes>
In [18]:
sns.catplot(x="Age",y="Region",kind='box',hue='Gender',data=UKBankCust)
Out[18]:
<seaborn.axisgrid.FacetGrid at 0x2aa73e387f0>
In [19]:
sns.catplot(x="Age",y="Region",kind='violin',data=UKBankCust)
Out[19]:
<seaborn.axisgrid.FacetGrid at 0x2aa73f46a90>
In [27]:
ax = sns.catplot(x='Region',y='Balance',hue='Gender',kind='point',data=UKBankCust)
ax.fig.autofmt_xdate()
In [9]:
import plotly.graph_objects as go
import plotly as py

data = [go.Bar(x=df.Region,
            y=df.Gender)]


py.plot(data, filename='jupyter-basic_bar')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-053852559af0> in <module>
      6 
      7 
----> 8 py.plot(data, filename='jupyter-basic_bar')

TypeError: plot() missing 1 required positional argument: 'kind'
In [18]:
plt.style.use('classic')
In [23]:
# ------- file: myplot.py ------
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(r"C:\Users\Tatan\UKBankCust.csv")

plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))

plt.show()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-b111b92a58a7> in <module>
      3 import numpy as np
      4 
----> 5 x = np.linspace(r"C:\Users\Tatan\UKBankCust.csv")
      6 
      7 plt.plot(x, np.sin(x))

<__array_function__ internals> in linspace(*args, **kwargs)

TypeError: _linspace_dispatcher() missing 1 required positional argument: 'stop'
In [28]:
import plotly.graph_objects as go
fig = go.Figure(
    data=[go.Bar(y=[2, 1, 3])],
    layout_title_text="A Figure Displayed with fig.show()"
)
fig.show()
In [1]:
import pandas as pd
import plotly.express as px

df = pd.read_csv(r"C:\Users\Tatan\UKBankCust.csv")

fig = px.line(df, x = 'Age', y = 'Balance', title='Age wise Balance of Customers')
fig.show()
In [2]:
import pandas as pd
import plotly.express as px

df = pd.read_csv(r"C:\Users\Tatan\UKBankCust.csv")

fig = px.line(df, x = 'Region', y = 'Balance', title='Wealthy Region')
fig.show()
In [3]:
import plotly.graph_objects as G
import numpy as N
 
 
n = 100
 
figure = G.Figure(data=[G.Mesh3d(x=(55*N.random.randn(n)),
                   y=(50*N.random.randn(n)),
                   z=(25*N.random.randn(n)),
                   opacity=0.8,
                   color='rgba(244,22,100,0.6)'
                  )])
 
 
 
figure.show()
In [ ]:
import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or any Plotly Express function e.g. px.bar(...)
# fig.add_trace( ... )
# fig.update_layout( ... )

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([
    dcc.Graph(figure=fig)
])

app.run_server(debug=True, use_reloader=False)  # Turn off reloader if inside Jupyter